import React, { useEffect, useState } from 'react'
import './AddReturncar.scss'
import {useNavigate, useSearchParams} from "react-router-dom"
import { PlusOutlined } from '@ant-design/icons';
import {
  Form,
  Input,
  Button,
  Radio,
  Select,
  Cascader,
  DatePicker,
  InputNumber,
  TreeSelect,
  Switch,
  Checkbox,
  Upload,
} from 'antd';
import * as service from '../../../../api/index'
import * as zzservice from '../../../../api/indexzz'




interface Props {

}
function AddReturncar(props:Props) {
  const { Option } = Select;
    let navigate=useNavigate()
    const [tu,setTu]=useState<any>('')
    const [form] = Form.useForm();

    const onFinish = async(values: any) => {
        values.pic=tu
        console.log('Success:', values);
          // var res=await service.car_addrecordcar(values)
          var res=await zzservice.car_addHcar(values)
        navigate('/index/Vehicle/returncar')
        
      };
      
      const onFinishFailed = (errorInfo: any) => {
        console.log('Failed:', errorInfo);
       
      };

    
     

       var onChange = (e:any)=>{
        var reader = new FileReader();
        reader.readAsDataURL(e.target.files[0])
        reader.onload = function(){
            setTu(this.result)
    }
  
    }
    return (
        <div className='addReturncar'>
              <div className="hai">
            <div className='hhh'>
                <div className="h"></div>
            <div className="hh1">新增还车登记</div>
            </div>
            <Button onClick={()=>{navigate(-1)}}>返回</Button>
            </div>
            <Form
            form={form}
        name="basic"
        labelCol={{ span: 8 }}
        wrapperCol={{ span: 16 }}
        style={{ maxWidth: 600 }}
        initialValues={{ remember: true }}
        onFinish={onFinish}
        onFinishFailed={onFinishFailed}
        autoComplete="off"
      >
       
       
       <Form.Item
         label="审批编号"
         name="ref"
         rules={[{ required: true, message: '审批编号不能为空!' }]}
        >
          <Input  placeholder='请输入'/>
        </Form.Item>
        
        <Form.Item 
        label="选择车辆"
        name="car"
        rules={[{ required: true, message: '车辆不能为空!' }]}
        >
         <Select placeholder="请选择">
           <Option value="商务专车">商务专车</Option>
        <Option value="研发部专车">研发部专车</Option>
        <Option value="设计部专车">设计部专车</Option>
        <Option value="行政部专车">行政部专车</Option>
        </Select>
        </Form.Item>
        
       
       
        <Form.Item 
        label="用车部门"
        name="branch"
        rules={[{ required: true, message: '用车部门不能为空!' }]}
        >
          <Input  placeholder='请输入'/>
        </Form.Item>
       
       
        
        <Form.Item
         label="用车人"
         name="sponsor"
         rules={[{ required: true, message: '用车人不能为空!' }]}
        >
          <Input  placeholder='请输入'/>
        </Form.Item>
       
        <Form.Item
         label="提交人"
         name="submitter"
         rules={[{ required: true, message: '提交人不能为空!' }]}
        >
          <Input  placeholder='请输入'/>
        </Form.Item>
        <Form.Item name="Submissiontime" label="出车时间" rules={[{ required: true, message: '出车时间不能为空!' }]}>
      <DatePicker showTime format="YYYY-MM-DD HH:mm:ss" />
    </Form.Item>
        <Form.Item >
          <Button type="primary" htmlType="submit" style={{marginLeft:180}}>
          
           新增
            </Button>
        </Form.Item>
      </Form>
        </div>
    );
}

export default AddReturncar;